package file;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class Texs {
	private static Texs texs;

	private Texs() {

	}

	public static Texs getTexs() {
		if (texs == null)
			texs = new Texs();
		return texs;
	}

	public void setParent(File parent) {
		this.parent = parent;
	}

	private File parent;

	public List<File> getTexList() {
		List<File> files = new ArrayList<File>();
		files = getTexList(parent);
		return files;
	}

	private List<File> getTexList(File p) {
		List<File> files = new ArrayList<File>();
		if (p.isDirectory()) {
			for (File file : p.listFiles()) {
				files.addAll(getTexList(file));
			}
		} else {
			if (p.getName().endsWith(".tex")) {
				files.add(p);
			}
		}
		return files;
	}

}
